<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1. 统计公平数对的数目
        // 暴力解法
        var countFairPairs = function(nums, lower, upper) {
            let ans = 0;
            for (let i = 0; i < nums.length; i++) {
                for (let j = i + 1; j < nums.length; j++) {
                    if (nums[i] + nums[j] >= lower && nums[i] + nums[j] <= upper) {
                        ans++
                    }
                }
            }
            return ans
        };
        console.log(countFairPairs([0,1,7,4,4,5], 3, 6), 'countFairPairs');
        console.log(countFairPairs([1,7,9,2,5], 11, 11), 'countFairPairs');
    </script>
</body>

</html>